
import { storeToRefs } from 'pinia'
import { useUserStore } from '@/stores/useUser'
import { useRouter ,useRoute} from 'vue-router'
const useUser = useUserStore();
const { checkedKeys, adminname } = storeToRefs(useUser);

// ======按钮权限=====
export const premission = () => {
    const router = useRouter()
    const route = useRoute()
    // 1. admin这个人进去，不进行权限判断
    if (adminname.value != 'admin') {
        // 2. 进行权限判断
        // 当你之前添加管理员的时候给这个管理员设置的权限列表中不存在当前访问的路由的时候，就让他跳转到/np组件中
        console.log("-------", checkedKeys.value.includes(route.path));
        if (!checkedKeys.value.includes(route.path)) {
            router.push("/np")
        }
    }
}
